package com.dongge;

import com.dongge.data.Info;
import com.dongge.data.JdbcLearn;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * Created by zhudong on 2016/8/16.
 */
public class JdbcMain {
    @Test
    public void jdbcTemplate(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("annotation-tx.xml");
        JdbcLearn jdbcLearn = (JdbcLearn)applicationContext.getBean("jdbcLearn");
        System.out.println(jdbcLearn);
        System.out.println(jdbcLearn.getRecordsNum());
    }

    @Test
    public void testConditionalQuery(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("annotation-tx.xml");
        JdbcLearn jdbcLearn = (JdbcLearn)applicationContext.getBean("jdbcLearn");
        Info info = jdbcLearn.conditionalQuery("dongge");
        info.print();
        List<Info> infos = jdbcLearn.getInfoList();
        for(Info info1:infos){
            info1.print();
        }
    }
}
